package com.gq.webstore.hdzw.util;

public class ContentUtil {
    public static String cutFromFirst(String content, String first, String last) {
        return cutFromFirst(content,first,last,true);
    }
        public static String cutFromFirst(String content, String first, String last,boolean mustLast) {
        int s1 =0;
        if(first!=null&&!first.isEmpty()){
            s1 = content.indexOf(first);
            if (s1 < 0) {
                throw new RuntimeException("cannot find first,first:" + first + ",last:" + last+",content:" + content);
            }
            s1 = s1 + first.length();
        }
        if(last == null|| last.isEmpty()){
            return content.substring(s1);
        }
        int end = content.indexOf(last, s1);
        if (end < 0) {
            if(mustLast){
                throw new RuntimeException("cannot find last,first:" + first + ",last:" + last+",content:" + content);
            }else{
                end=content.length();
            }
        }
        return content.substring(s1, end);
    }

    public static void main(String[] args) {
        System.out.println(cutFromFirst("123123123898989666666342363435","23","6"));
    }
}
